home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
v9n07.arc
/
HEAPBUG.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1990-03-16
|
661b
|
26 lines
program HeapBug;
CONST AllocSize : Word = $8000;
VAR
P : ARRAY[0..1] OF Pointer;
flip : byte;
PrevAlloc : Word;
BEGIN
flip := 0;
REPEAT
PrevAlloc := AllocSize;
WHILE MaxAvail < AllocSize DO
AllocSize := AllocSize DIV 2;
GetMem(P[flip], AllocSize);
Write('Allocated ', AllocSize:6 ,' bytes ');
Write('to pointer #', flip);
WriteLn(' -- MaxAvail is ',MaxAvail:8);
flip := succ(flip) MOD 2;
UNTIL MaxAvail <= 16;
Write('Deallocating ', PrevAlloc ,' bytes ');
WriteLn('from pointer #', flip);
FreeMem(P[flip], PrevAlloc);
WriteLn('NO crash -- FreeMin = ',FreeMin);
END.